package com.example.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class DemoAspect {

    @Around("bean(*Controller)")
    public Object excTime(ProceedingJoinPoint joinPoint){
        Object proceed=null;
        try {
            long start = System.currentTimeMillis();
            System.out.println("开始时间："+start);
            proceed = joinPoint.proceed();
            long end = System.currentTimeMillis();
            System.out.println("结束时间："+end);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return proceed;
    }
}
